package com.zby.business.net;




import java.io.BufferedReader;
import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by BY on 2016/3/5.
 */
public class HttpClient {
    private static URL url;
    private static HttpURLConnection conn;

    public static String requestByGet(String request) {
        String address = request;
        System.out.println(address);
        try {
            url = new URL(address);
            conn = (HttpURLConnection) url.openConnection();
            conn.setConnectTimeout(2000);
            conn.connect();
            InputStream is = conn.getInputStream();
            BufferedReader br = new BufferedReader(new InputStreamReader(is));
            System.out.println(conn.getResponseCode());
            String line = "";
            StringBuffer sb = new StringBuffer();
            while ((line = br.readLine()) != null) {
                sb.append(line);
            }
            return sb.toString();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "";
    }

    public static String requestByPost(String address, Map<String, String> params, Map<String, File> files) {
        try {

        } catch (Exception e) {
            e.printStackTrace();
        }
        return "";
    }
}
